<%--
 *  File:    AgreementUpload.jsp
 *  @Author: myl
 *  Date:    2016/01/27
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
	//init param
	String privilegeCode = "11302";
	String strTableName = "";
	String strModuleName = "COM";
	String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc"%>
<%@ include file="/inc/OvalLocationDefault.inc"%>
<%@ include file="/rpt/ReportURL.inc"%>

<html>
<head>
<title>AgreementUpload</title>
<PageFlow:CheckPageFlow pageName="p_uptmpzmylagreement" />
<%@ include file="/inc/CatchError.inc"%>
<%
	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
	if(totalsummary == null){
		totalsummary = new Vector();
	}
	
	Vector propertys = (Vector)pageContext.getAttribute("propertys");
	if(propertys == null){
		propertys = new Vector();
	}
%>
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc"%>

<script language="JavaScript">
function page_summary(actionvalue,orderbyname){
	var editform = summaryPrepare(cform,actionvalue,orderbyname);
	if(!editform) return;
	editform.action = "AgreementUpload.jsp?<%= OvalTools.randomURL() %>";
	editform.target = "_self";
	isRunning = true;
	editform.submit();
}

function page_operate(operand){
	if(cform.filename.value === "" || cform.filename.value === null){
		return false;
	}
	if (operand=="upload"){
	  cform.encoding="multipart/form-data";
	  cform.actionname.value = "upload";
	  cform.target = "_self";
	  cform.submit();
	}
}

function page_check(flag){
	if(flag == 'giveup'){
		var giveflag = confirm("<%= message.getMessageDesc("SURE_GIVE_UP")%>");
		if(!giveflag){
			return;
		}
	}
	cform.flag.value = flag;
	cform.actionname.value = "check";
	cform.target = "_self";
	isRunning = true;
	cform.submit();
}
</script>
</head>

<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">	
	<input type="hidden" name="pagename" value="p_uptmpzmylagreement">
	<input type="hidden" name="actionname">
	<input type="hidden" name="sheetname" value="agreement">
	<input type="hidden" name="flag">
	<%@ include file="/inc/PageLocation.inc"%>

<table width="100%" cellspacing="0" border="0" cellpadding="0">
	<tr>
		<td>
			<table width="100%" border="0" cellspacing="0">
				<tr>
					<td>
						<%= label.getLabelName("L_Path") %><%= label.getLabelName("L_Colon") %>
						<input type="file" name="filename" size="30">&nbsp;&nbsp;&nbsp;&nbsp;
						<a onclick="page_operate('upload')"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60" /></a>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
		<div style="overflow:auto;width:1320;height:400">
		<table border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
			<tr class="deepblue-left">
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_ErrorMsg") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_ProtocolCode") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_ProtocolName") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_AgreementType") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_FirstOrg") + label.getLabelName("L_Code") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_FirstOrg")+label.getLabelName("L_Name") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_SecondOrg")+label.getLabelName("L_Code") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_SecondOrg")+label.getLabelName("L_Name") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_AgreementProduct") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_ZMYLStartDate") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_ZMYLExpireDate") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_Protocols") +label.getLabelName("L_SalesScope") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_AgreementAmount") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_quartersales1") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_quartersales2") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_quartersales3") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_quartersales4") %><%= label.getLabelName("L_Name") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_Protocols") + label.getLabelName("L_SignDate") %></td>
				<td class="title_center" nowrap="nowrap"><%= label.getLabelName("L_SupplementarySpecification") %></td>
				<logic:iterate id="property" collection="<%= propertys %>" scope="page">
				<td class="title_center" nowrap="nowrap"><custom:write property="configname" name="property" /></td>
				</logic:iterate>
			</tr>
			<%
				int i = 0;
				String strClassType = "";
				String checkflag = null;
			%>
			<logic:iterate id="onerow" collection="<%= totalsummary %>" scope="page">
			<%
				if(i%2 == 1){
					strClassType = "td-listrom";
				}else{                    
					strClassType = "none";
				}
				i++;
				  
				HashMap row = (HashMap)pageContext.getAttribute("onerow");
				if(row.get("errormassage") != null){
					strClassType = "need";
				}
				if(checkflag == null){
					checkflag = (String)row.get("checkflag");
				}
			%>
			<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" class="<%=JspHelper.filterNull( strClassType )%>">
				<td nowrap="nowrap"><custom:write property="errormessage" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="agreementcode" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="agreementname" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="configname" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="partyacode" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="partyaname" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="partybcode" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="partybname" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="prodname" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="startdate" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="expiredate" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="salesscope" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="amount" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="quartersales1" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="quartersales2" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="quartersales3" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="quartersales4" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="signdate" name="onerow" nbsp="true" /></td>
				<td nowrap="nowrap"><custom:write property="comments" name="onerow" nbsp="true" /></td>
				<%
					String propertyname = "";
					for(int j = 1;j <= propertys.size();j++){
						propertyname = "property" + j;
				%>
				<td nowrap="nowrap"><%=JspHelper.filterNull(row.get(propertyname))%></td>
				<%
					}
				%>
			</tr>
			</logic:iterate>
			<tr>
				<td colspan="118" align="left"><%= label.getLabelName("L_TotalData") + label.getLabelName("L_Colon") %><custom:write property="count" name="count" nbsp="true" /></td>
			</tr>
		</table>
		</div>
		<%@ include file="/inc/SummaryActionUP.inc"%>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
			<tr>
				<td class="td_center">
					<%
						if (totalsummary.size() > 0){
		      				if(checkflag == null){
					%>
					<a onclick="page_check('check');"><custom:button type="1" label="L_CheckContent" imgsrc="new.gif" border="0" style="width:60" /></a>
					<%
							}else if(("Y").equals(checkflag)){
					%>
					<a onclick="page_check('confirm');"><custom:button type="1" label="L_Submit1" imgsrc="new.gif" border="0" style="width:60" /></a>
					<a onclick="page_check('giveup');"><custom:button type="1" label="L_GiveUp" imgsrc="new.gif" border="0" style="width:60" /></a>
					<%
							}
		      			}
					%>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</form>
</body>
</html>
